package com.drug.web.controller.wms;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.drug.common.annotation.Log;
import com.drug.common.core.controller.BaseController;
import com.drug.common.core.domain.AjaxResult;
import com.drug.common.enums.BusinessType;
import com.drug.wms.domain.BusGoodsPriceRelation;
import com.drug.wms.service.IBusGoodsPriceRelationService;
import com.drug.common.utils.poi.ExcelUtil;
import com.drug.common.core.page.TableDataInfo;

/**
 * 商品-价格关联Controller
 * 
 * @author ruoyi
 * @date 2021-11-09
 */
@RestController
@RequestMapping("/wms/relation")
public class BusGoodsPriceRelationController extends BaseController
{
    @Autowired
    private IBusGoodsPriceRelationService busGoodsPriceRelationService;

    /**
     * 查询商品-价格关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:relation:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusGoodsPriceRelation busGoodsPriceRelation)
    {
        startPage();
        List<BusGoodsPriceRelation> list = busGoodsPriceRelationService.selectBusGoodsPriceRelationList(busGoodsPriceRelation);
        return getDataTable(list);
    }

    /**
     * 导出商品-价格关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:relation:export')")
    @Log(title = "商品-价格关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusGoodsPriceRelation busGoodsPriceRelation)
    {
        List<BusGoodsPriceRelation> list = busGoodsPriceRelationService.selectBusGoodsPriceRelationList(busGoodsPriceRelation);
        ExcelUtil<BusGoodsPriceRelation> util = new ExcelUtil<BusGoodsPriceRelation>(BusGoodsPriceRelation.class);
        return util.exportExcel(list, "商品-价格关联数据");
    }

    /**
     * 获取商品-价格关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:relation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(busGoodsPriceRelationService.selectBusGoodsPriceRelationById(id));
    }

    /**
     * 新增商品-价格关联
     */
    @PreAuthorize("@ss.hasPermi('system:relation:add')")
    @Log(title = "商品-价格关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusGoodsPriceRelation busGoodsPriceRelation)
    {
        return toAjax(busGoodsPriceRelationService.insertBusGoodsPriceRelation(busGoodsPriceRelation));
    }

    /**
     * 修改商品-价格关联
     */
    @PreAuthorize("@ss.hasPermi('system:relation:edit')")
    @Log(title = "商品-价格关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusGoodsPriceRelation busGoodsPriceRelation)
    {
        return toAjax(busGoodsPriceRelationService.updateBusGoodsPriceRelation(busGoodsPriceRelation));
    }

    /**
     * 删除商品-价格关联
     */
    @PreAuthorize("@ss.hasPermi('system:relation:remove')")
    @Log(title = "商品-价格关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(busGoodsPriceRelationService.deleteBusGoodsPriceRelationByIds(ids));
    }
}
